package com.halfsword.creativecraft.gui;

import com.halfsword.creativecraft.CreativeCraft;
import com.halfsword.creativecraft.gui.machine.SpaceCollectorMenu;
import com.halfsword.creativecraft.gui.machine.SteamCrusherMenu;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraftforge.common.extensions.IForgeMenuType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.network.IContainerFactory;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;


public class MenuTypes {
    public static final DeferredRegister<MenuType<?>> MENUS =
            DeferredRegister.create(ForgeRegistries.MENU_TYPES, CreativeCraft.MOD_ID);
    public static final RegistryObject<MenuType<SpaceCollectorMenu>> SPACE_COLLECTOR_MENU=
            registerMenuType("space_collector_menu",SpaceCollectorMenu::new);
    public static final RegistryObject<MenuType<SteamCrusherMenu>> STEAM_CRUSHER_MENU=
            registerMenuType("steam_crusher_menu",SteamCrusherMenu::new);
    private static <T extends AbstractContainerMenu>RegistryObject<MenuType<T>> registerMenuType(String name, IContainerFactory<T> factory){
        return MENUS.register(name,()-> IForgeMenuType.create(factory));
    }



    public static void register(IEventBus eventBus ) {
        MENUS.register(eventBus);
    }
}
